<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>属性选择器</title>
  <style>
    *{
      margin: 0;
      padding:0;
    }
    ul{
      padding-left: 10px;
      width: 800px;
      height: 160px;
      margin: 20px auto;
      background-color: pink;
    }
    li{
      float: left;
      list-style: none;
      width: 50px;
      height: 50px;
      background-color: #005971;
      margin: 10px;
    }

    .demo1 li[class]{
      background-color: #218300;
    }
    .demo2 li[class="lable"]{
      background-color: #218300;
    }
    .demo3 li[class^="lable"]{
      background-color: #218300;
    }
    .demo4 li[class$="_"]{
      background-color: #218300;
    }
    .demo5 li[class*="_"]{
      background-color: #218300;
    }
    .tips{
      position: absolute;
      top: 0;
      right: 50%; 
      margin-right: 420px;
      padding-left: 0;
      width: 70px;
      height: 140px;
      color:  white;
      font-size: 12px;
    }
    .checked{
      background-color: #218300;
    }
    .default{
      background-color: #005971;
    }

  </style>
</head>

<body>
  <ul class="tips">
    <li class="checked">选中颜色</li>
    <li class="default">默认颜色</li>
  </ul>
  <ul class="demo1">
    <p> li[class] {background-color: #218300;}</p>
    <li class="lable"></li>
    <li class="lable"></li>
    <li class="lable"></li>
    <li class="lable"></li>
    <li></li>
    <li></li>
    <li></li>
  </ul>
  <ul class="demo2">
    <p> li[class="lable"] {background-color: #218300;}</p>
    <li class="lable"></li>
    <li class="lable"></li>
    <li class="lable_1"></li>
    <li class="lable_1"></li>
    <li class="lable_2"></li>
    <li class="lable_2"></li>
    <li class="lable_2"></li>
    <li class="lable_3"></li>
    <li class="lable_3"></li>
  </ul>
  <ul class="demo3">
    <p> li[class^="lable"] {background-color: #218300;}</p>
    <li class="lable"></li>
    <li class="lable"></li>
    <li class="lable_1"></li>
    <li class="lable_1"></li>
    <li class="lable_2"></li>
    <li class="lable_2"></li>
    <li class="lable_2"></li>
    <li class="lable_3"></li>
    <li class="lable_3"></li>
  </ul>
  <ul class="demo4">
    <p> li[class$="_"] {background-color: #218300;}</p>
    <li class="lable"></li>
    <li class="lable"></li>
    <li class="lable_1_"></li>
    <li class="lable_1_"></li>
    <li class="lable_2_"></li>
    <li class="lable_2_"></li>
    <li class="lable_2_"></li>
    <li class="lable_3"></li>
    <li class="lable_3"></li>
  </ul>
  <ul class="demo5">
    <p> li[class*="_"] {background-color: #218300;}</p>
    <li class="lable"></li>
    <li class="lable"></li>
    <li class="lable_1_"></li>
    <li class="lable_1_"></li>
    <li class="lable_2_"></li>
    <li class="lable_2_"></li>
    <li class="lable_2_"></li>
    <li class="lable_3"></li>
    <li class="lable_3"></li>
  </ul>
</body>

</html>